package com.itheima.es.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;


import com.itheima.es.mapper.SkuMapper;
import org.springframework.stereotype.Service;
import com.itheima.es.po.Sku;
import com.itheima.es.service.SkuService;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku> implements SkuService {
    @Override
    public List<Sku> findAllSku() {
        return baseMapper.findAllSku();

    }

    @Override
    public Map findAllSkuByPage(Integer currentPage, Integer pageSize) {
        // 2. page方法返回查询结果
        Page<Sku> page = page(new Page<Sku>(currentPage, pageSize));
        List<Sku> records = page.getRecords();
        long total = page.getTotal();
        Map<String, Object> map = new HashMap<>();
        map.put("result", records);
        map.put("total", total);
        return map;
    }

}
